namespace DesignPattern.Decorator.Refactored
{
    public class DecoratedTextFileLogger : ILogger
    {
        private readonly ILogger _logger;
        private readonly ITextFileWritter _textFileWritter;

        public DecoratedTextFileLogger(ITextFileWritter textFileWritter, ILogger logger)
        {
            _textFileWritter = textFileWritter;
            _logger = logger;
        }

        public void Write(string message)
        {
            _textFileWritter.Write(message);
            if (_logger != null)
                _logger.Write(message);
        }
    }

    public class DecoratedMSMQLogger : ILogger
    {
        private readonly ILogger _logger;
        private readonly IMSMQWritter _msmqWritter;

        public DecoratedMSMQLogger(IMSMQWritter textFileWritter, ILogger logger)
        {
            _msmqWritter = textFileWritter;
            _logger = logger;
        }

        public void Write(string message)
        {
            _msmqWritter.Write(message);

            if (_logger != null)
                _logger.Write(message);
        }
    }

    public class DecoratedDatabaseLogger : ILogger
    {
        private readonly ILogger _logger;
        private readonly IDatabaseWritter _databaseWritter;
        public DecoratedDatabaseLogger(IDatabaseWritter textFileWritter, ILogger logger)
        {
            _databaseWritter = textFileWritter;
            _logger = logger;
        }

        public void Write(string message)
        {
            _databaseWritter.Write(message);
            if (_logger != null)
                _logger.Write(message);
        }
    }
}